{% extends "front/settings.html" %}

{% block content %}
    <div class="post-management-container">
        <div class="post-management-header">
            <h2>帖子管理</h2>
        </div>

        {% if posts %}
            <div class="posts-list">
            {% for post in posts %}
                <div class="post-item">
                    <div class="post-content">
                        <h3 class="post-title">{{ post.title }}</h3>
                        <div class="post-meta">
                            <span class="post-date">发布时间：{{ post.create_time.strftime('%Y-%m-%d %H:%M') }}</span>
                            <span class="post-category">分类：{{ post.board.name if post.board else '未分类' }}</span>
                        </div>
                    </div>
                    <div class="post-actions">
                        <a href="{{ url_for("front.edit_post", post_id=post.id) }}" class="btn btn-primary btn-sm">
                            <i class="fas fa-edit"></i> 编辑
                        </a>
                        <button type="button" class="btn btn-danger btn-sm delete-post" id="delete-btn"
                                data-post-id="{{ post.id }}">
                            <i class="fas fa-trash"></i> 删除
                        </button>
                    </div>
                </div>
            {% endfor %}
            <div style="text-align:center;">
                {{ pagination.links }}
            </div>
        {% else %}
            <div class="no-posts">
                <p>您还没有发布任何帖子。</p>
                <a href="{{ url_for("front.post_public") }}" class="btn btn-primary" target="_blank">发布新帖子</a>
            </div>
        {% endif %}
        </div>
    </div>
{% endblock %}